package org.dizem.intellipainter.component.media;

import javax.swing.*;
import java.applet.Applet;
import java.awt.*;

/**
 * User: dizem@126.com
 * Time: 12-2-19 下午9:51
 */
public class MediaPanel extends JPanel {
	private static final Font font = new Font("微软雅黑", Font.PLAIN, 13);
	private static final Dimension SIZE = new Dimension(78, 100);
	private final MusicButton musicButton = new MusicButton();
	private final AnimationButton animationButton;

	public MediaPanel(AnimationCallback callback) {
		animationButton = new AnimationButton(callback);
		setLayout(new BorderLayout());
		setPreferredSize(SIZE);
		setMaximumSize(SIZE);
		setMinimumSize(SIZE);
		add(createCenter(), BorderLayout.CENTER);
		add(createSouth(), BorderLayout.SOUTH);
	}

	public void init(Applet applet) {
		musicButton.init(applet);
	}

	private JPanel createCenter() {
		JPanel center = new JPanel(new FlowLayout());
		center.add(musicButton);
		center.add(animationButton);
		return center;
	}

	private JLabel createSouth() {
		JLabel label = new JLabel("多媒体", JLabel.CENTER);
		label.setFont(font);
		label.setForeground(Color.GRAY);
		label.setPreferredSize(new Dimension(78, 20));
		return label;
	}

}
